#!/usr/bin/env python
# -*- conding: utf-8 -*-

"""
@Time     : 2024/8/27 6:36
@Author   : liujingmao
@File     : 1.bind函数使用技巧.py
"""

import dotenv
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

# 1. 加载环境变量
dotenv.load_dotenv()

# 2. 创建Prompt
prompt = ChatPromptTemplate.from_messages([
    ("human", "{query}")
])

# 3. 创建llm
llm = ChatOpenAI(model="gpt-3.5-turbo")

# 4. 创建chain
chain = prompt | llm.bind(model="gpt-4o") | StrOutputParser()

content = chain.invoke({"query": "你是什么模型呢？"})
# 5. 打印content
print(content)
